how to write logic for registration in php